package com.itany.corejava.code08_常用类.内部类;

import com.itany.corejava.code08_常用类.内部类.OuterThree.InnerThree;

/**
 * @author 石小俊
 * 2024年07月23日 16:25
 */
public class Test03_静态内部类 {

    public static void main(String[] args) {
        OuterThree outer = new OuterThree();
        outer.show();
        //OuterThree.InnerThree inner = new OuterThree.InnerThree();
        InnerThree inner = new InnerThree();
        System.out.println(inner.getName());
        inner.print();
    }

}

class OuterThree {
    private String name = "admin";
    private int age;
    private static String phone = "13812345678";

    public OuterThree() {
    }

    public OuterThree(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void show() {
        System.out.println("*********************外部类方法*********************");
        InnerThree inner = new InnerThree();
        System.out.println(inner.name);
    }

    static class InnerThree {
        private String name = "alice";
        private String gender;

        public void print() {
            System.out.println("*********************内部类方法*********************");
            System.out.println(name);
            // 在静态内部类中访问外部类属性时,只能访问静态属性
            //System.out.println(age);
            System.out.println(phone);
            OuterThree outer = new OuterThree();
            System.out.println(outer.name);
            System.out.println(outer.age);
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getGender() {
            return gender;
        }

        public void setGender(String gender) {
            this.gender = gender;
        }
    }
}
